namespace PHMEE.PHM.Algorithms.Basic;

/// <summary>
/// 傅里叶变换算法
/// </summary>
public class FftAlg
{
    private readonly FftService.FftServiceClient _client;

    public FftAlg(FftService.FftServiceClient client)
    {
        _client = client;
    }

    /// <summary>
    /// 傅里叶变换算法
    /// </summary>
    /// <param name="accData">加速度 振动信号时域序列</param>
    /// <param name="sampleRate">采样频率</param>
    /// <returns></returns>
    public FftResponse Fft(float[] accData, float sampleRate)
    {
        var request = new FftRequest
        {
            AccData = {accData},
            SampleRate = sampleRate
        };

        return _client.FftAlg(request);
    }
    
    /// <summary>
    /// 傅里叶变换算法
    /// </summary>
    /// <param name="accData">加速度 振动信号时域序列</param>
    /// <param name="sampleRate">采样频率</param>
    /// <returns></returns>
    public async Task<FftResponse> FftAsync(float[] accData, float sampleRate)
    {
        var request = new FftRequest
        {
            AccData = {accData},
            SampleRate = sampleRate
        };
        
        return await _client.FftAlgAsync(request);
    }
}